package com.ysyx.ysyx_ordersetstatu.mqlistener;

import com.ysyx.ysyx_ordersetstatu.service.OrderPojoService;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 *
 * @description: xxxx接口/类
 * @author:郭宇轩
 * @create:2023/4/15 15:15
 */
@Component
@RocketMQMessageListener(topic = "order",selectorExpression="driverCancel" ,consumerGroup = "driverCancel_cGroup")
public class OrderDriverCancelListener implements RocketMQListener<MessageExt>, RocketMQPushConsumerLifecycleListener {

    @Autowired
    private OrderPojoService orderPojoService;

    @Override
    public void onMessage(MessageExt messageExt) {
        System.out.println("司机取消订单MQ=="+new String(messageExt.getBody()));
        String orderId = new String(messageExt.getBody());
        orderPojoService.driverCancelDaoMQ(orderId);


    }

    @Override
    public void prepareStart(DefaultMQPushConsumer defaultMQPushConsumer) {

    }
}
